﻿@using System.Security.Claims
@model string

<div class="container py-5">
    <div class="row justify-content-center">
        <div class="col-md-8">
            @if (User?.Identity is { IsAuthenticated: true })
            {
                <div class="card shadow-sm mb-4">
                    <div class="card-body">
                        <h2 class="card-title mb-3">欢迎，@User.Identity.Name</h2>
                        <h5 class="mb-2">您的Claims：</h5>
                        <ul class="list-group mb-3">
                            @foreach (var claim in Context.User.Claims)
                            {
                                <li class="list-group-item d-flex justify-content-between align-items-center">
                                    <span class="text-muted">@claim.Type</span>
                                    <span class="fw-bold">@claim.Value</span>
                                </li>
                            }
                        </ul>
                        @if (!string.IsNullOrEmpty(Model))
                        {
                            <div class="alert alert-info" role="alert">
                                <strong>控制器返回消息：</strong> @Model
                            </div>
                        }
                        <div class="d-flex gap-2">
                            <form asp-action="Index" asp-controller="Home" method="post" class="d-inline">
                                <button class="btn btn-warning" type="submit">戳一下，验证认证授权状态</button>
                            </form>
                            <form asp-action="Logout" asp-controller="Auth" method="post" class="d-inline">
                                <button class="btn btn-danger" type="submit">退出</button>
                            </form>
                        </div>
                    </div>
                </div>
            }
            else
            {
                <div class="card shadow-sm text-center">
                    <div class="card-body">
                        <h2 class="card-title mb-4">欢迎，游客</h2>
                        <a class="btn btn-success btn-lg" asp-controller="Auth" asp-action="Login">
                            通过 OIDC 登录
                        </a>
                    </div>
                </div>
            }
        </div>
    </div>
</div>